package net.wzyjerry.springboot.demo.repository;

import net.wzyjerry.springboot.demo.model.Value;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * Created by WzyJerry on 2017/10/21.
 * Value Repository
 */
public interface ValueRepository extends JpaRepository<Value, Integer> {

    /**
     * Get the position of the entity(id)
     *
     * @param id Entity id
     * @return Position
     */
    @Query("select count(v) from Value v where v.id <= :id")
    Integer GetPosition(@Param("id") Integer id);
}
